<?php
session_start ();
date_default_timezone_set("PRC");
include ("conn/conn.php");
$name = $_POST ["usernc"];
$pwd1 = $_POST ["p1"];
$pwd = md5 ( $_POST ["p1"] );
$email = $_POST ["email"];
$truename = $_POST ["truename"];
$sfzh = $_POST ["sfzh"];
$tel = $_POST ["tel"];
$qq = $_POST ["qq"];
if ($_POST ["ts1"] == 1) {
	$tishi = $_POST ["ts2"];
} else {
	$tishi = $_POST ["ts1"];
}
$huida = $_POST ["tsda"];
$regtime = date ( "Y-m-j" );
$dongjie = 0;
$sql = mysqli_query ( $conn, "select * from tb_user where name='" . $name . "'" );
$info = mysqli_fetch_array ( $sql );
if ($info == true) {
	echo "<script>alert('该昵称已经存在!');history.back();</script>";
	exit ();
} else {
	mysqli_query ( $conn, "insert into tb_user (name,pwd,dongjie,email,truename,sfzh,tel,qq,tishi,huida,regtime,pwd1) values ('$name','$pwd','$dongjie','$email','$truename','$sfzh','$tel','$qq','$tishi','$huida','$regtime','$pwd1')" );
	//var_dump( $sql8 );exit();测试语句
	//$_SESSION["username"] = "username";这句话写的有问题
	$_SESSION["username"] = $name;
	//$username = $name; 这句话有什么用处
	$_SESSION["producelist"] = "producelist";
	$producelist = "";
	$_SESSION["quatity"] = "quatity";
	$quatity = "";
	echo "<script>alert('恭喜，注册成功!');window.location='index.php';</script>";
}
?>
